package org.jeecg.modules.wlhy.shipping.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.api.controller.ShippingVo;
import org.jeecg.modules.api.wlhy.customer.HyShippingNoteTongJiDTO;
import org.jeecg.modules.wlhy.customer.entity.HyCustomer;
import org.jeecg.modules.wlhy.customer.entity.HyCustomerCompany;
import org.jeecg.modules.wlhy.hydriver.entity.HyDriver;
import org.jeecg.modules.wlhy.hyinsurance.dto.InsuranceApplyDto;
import org.jeecg.modules.wlhy.hyvehicle.entity.HyVehicle;
import org.jeecg.modules.wlhy.hyzyb.dto.ShippingFenceTriggerDTO;
import org.jeecg.modules.wlhy.order.entity.HyOrder;
import org.jeecg.modules.wlhy.order.entity.HyOrderPrice;
import org.jeecg.modules.wlhy.shipping.dto.ImportUpdateShippingNoteDTO;
import org.jeecg.modules.wlhy.shipping.dto.LnTaxShippingNoteDTO;
import org.jeecg.modules.wlhy.shipping.entity.*;
import org.jeecg.modules.wlhy.shipping.vo.ZybShippingNoteVO;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;

public interface IHyShippingNoteService extends IService<HyShippingNote> {

    int getCountByDate(String dateString);

    void calcCoss(HyShippingNote hyShippingNote);

    HyShippingNote queryByShippingNoteNumber(String shippingNoteNumber);

    List<ShippingMonthTotalDTO> getShippingMonthTotal(String customerId , String startMonth , String endMonth);

    String buildWaterMarkImg(HyShippingNote shippingNote, String imgUnloading, String type);

    IPage <HyShippingNoteDTO> getPageList(Page <HyShippingNoteDTO> page, QueryWrapper <HyShippingNoteDTO> queryWrapper);

    IPage <LnTaxShippingNoteDTO> getLnTaxPageList(Page <LnTaxShippingNoteDTO> page, QueryWrapper <LnTaxShippingNoteDTO> queryWrapper);

    IPage <HyShippingNoteDTO> getPageCheckList(Page <HyShippingNoteDTO> page, QueryWrapper <HyShippingNoteDTO> queryWrapper);

    void saveBatchShippingNote(List<HyShippingNote> list);

    List<HyShippingNoteDTO> getList(QueryWrapper<HyShippingNoteDTO> queryWrapper);

    HyShippingNote addByOrder(HyOrder order, HyDriver driver , String companyId);

    Result<?> addByOrder(HyOrder order, HyDriver driver, HyVehicle vehicle, HyOrderPrice orderPrice,String shippingContract ,String shippingContract2, String driverBankId);

    void getWatermarkPic(HyShippingNote hyShippingNote,String imgLoading,String imgUnloading,String oldimgLoading,String oldImgUnloading);

    HyShippingNote ImportShippingNoteDTOTOShippingNote(ImportShippingNoteDTO importShippingNoteDTO, String toString) throws InterruptedException;

    List<ImportShippingNoteDTO> queryImportShippingNoteDTOS(List<ImportShippingNoteDTO> list);

    /**
     * 悲观锁，需配合 @Transactional
     * @param id
     * @return
     */
    HyShippingNote getByIdForUpdate(String id);

    /***
     * 悲观锁，需配合 @Transactional
     * @param ids
     * @return
     */
    List<HyShippingNote> listByIdsForUpdate(Collection<? extends Serializable> ids);

    List<HyShippingNote> getListByInvoiceId(String InoiveId);


    HyShippingNoteTongJiDTO sameDayList(String id, String i);

    HyShippingNoteTongJiDTO sameDayListSql(String id, String i,String sql,String starData,String endData);

    IPage<HyShippingNoteTongJiDTO> intransitList(Page<HyShippingNoteTongJiDTO> page,QueryWrapper<HyShippingNoteTongJiDTO> queryWrapper,String id, String i);


    List<HyShippingNoteTongJiDTO> sameDayList2(String id, String s);

    List<HyShippingNoteTongJiDTO> sameDayList2Sql(String id, String s,String sql);

    List<HyShippingNote> signedList(String id, String orderId);

    IPage<HyShippingNoteDTO> tongjiList(Page<HyShippingNoteTongJiDTO> page,QueryWrapper<HyShippingNoteTongJiDTO> queryWrapper,String s, String id, String orderId,String sql);

    IPage<HyShippingNoteDTO> tongjiRqList(Page<HyShippingNoteTongJiDTO> page,QueryWrapper<HyShippingNoteTongJiDTO> queryWrapper,String s, String id, String orderId,String star,String end);


    IPage<HyShippingNoteTongJiDTO> sameDayList2SqlW(Page<HyShippingNoteTongJiDTO> page,QueryWrapper<HyShippingNoteTongJiDTO> queryWrapper, String customerId,  String sql,String starData,String endData);


    BigDecimal getDriverDjsFeeByDriverId(String driverId);

    BigDecimal getDriverTotalFeeByDriverIdAndChannel(String driverId , String payChannel);

    BigDecimal getCustomerDjsFee(String customerId);

    BigDecimal getCustomerTotalFeeByChannel(String customerId, String channelType);

    /**
     * 查询实付运费合计  companyId 和 channelType 不传 查询所有公司， 所有 渠道的 合计
     * @param companyId   分公司id
     * @param channelType 支付渠道
     * @return
     */
    BigDecimal getTotalCostPayShipping(String companyId, String channelType);

    /**
     * 查询服务费合计  companyId 和 channelType 不传 查询所有公司， 所有渠道的 合计
     * @param companyId   分公司id
     * @param channelType 支付渠道
     * @return
     */
    BigDecimal getTotalCostService(String companyId, String channelType);

    /**
     * 修改运费风控需司机确认
     * @param
     * @return
     */
     void ModifyFreightRiskControl(HyShippingNote oldShipping,HyShippingNote newShipping);


    HyShippingNote getByShippingNoteNumer(String shippingNoteNumber);

    List<ShippingVo> getLuXian(String startMonth , String endMonth, String id);
    List<ShippingVo> getLuXian2(String startMonth , String endMonth, String id);

    List<ShippingVo> getLuXianName();

    //判断是否支付
    boolean checkIsPay(HyShippingNote shippingNote);

    Result jiedan(HyShippingNote shippingNote, String vehicleId);

    Result zybpaidan(ZybShippingNoteVO zybShippingNoteVO);

    Result zybComplete(ZybShippingNoteVO zybShippingNoteVO);

    //智运宝触发电子围栏后进行业务处理
    Result zybTrigger(ShippingFenceTriggerDTO shippingFenceTriggerDTO);

    boolean updateStatusByZybShippingNumber(String shippingNumber, String status, Date recvTime, String recvAddress, String recvAddressId);

    String getDriverFeeSum(String driverId);

    //查询当月司机运费合计，包含预付、分段预付和支付运费的合计
    Map<String, Map<String,BigDecimal>> getCurMonthDriverFee(String driverId);

    Map<String, Map<String,BigDecimal>> getCurMonthDriversFee(Collection<? extends Serializable> driverIds);

    List<ShuiWuExportShippingNoteDTO> guoShuiShippingExport(QueryWrapper<HyShippingNoteDTO> queryWrapper);

    Result saveInsurance(InsuranceApplyDto insuranceApplyDto);

    Result previewInsurance(String insuranceId);

    int count2(String driverId, String receiveAreaCode);

    HyOrder saveOrder(HyShippingNoteAndOrder shippingNote, HyCustomer customer, HyCustomerCompany hyCustomerCompany);

    Result importUpdateShippingNote(List<ImportUpdateShippingNoteDTO> importShippingNoteDTOList);

    Integer getCount(QueryWrapper<HyShippingNote> queryWrapper);

    Integer getZtCount(QueryWrapper<HyShippingNote> queryWrapper);

    List<ShuiWuExportShippingNoteDTO> guoShuiShippingExport2(QueryWrapper<HyShippingNoteDTO> queryWrapper);


}

